package com.dxy.lc.controller;

import com.dxy.lc.base.Resp;
import com.dxy.lc.model.bean.ChatHistoryQo;
import com.dxy.lc.model.bean.SetReadDto;
import com.dxy.lc.model.entity.Message;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.dxy.lc.service.MessageService;

import java.util.List;

/**
* <p>
*  controller
* </p>
*
* @author dxy
* @since 2024-11-07
*/
@Slf4j
@RestController
@RequestMapping("/lc/message")
public class MessageController {

    @Autowired
    private MessageService service;

    @PostMapping("/setReadById")
    public Resp setReadById(@RequestBody SetReadDto param){
        service.setReadById(param);
        return Resp.bizSuccess();
    }

    @PostMapping("/setReadByRoomId")
    public Resp setReadByRoomId(@RequestBody SetReadDto param){
        service.setReadByRoomId(param);
        return Resp.bizSuccess();
    }

    @GetMapping("/getChatHistory")
    public Resp<List<Message>> getChatHistory(ChatHistoryQo param){
        return Resp.bizSuccess(service.getChatHistory(param));
    }

    @GetMapping("/getUnreadCount")
    public Resp getUnreadCount() {
        return Resp.bizSuccess(service.getUnreadCount());
    }

}